import time

import pytest
from selenium.webdriver.common.by import By

from Base.base import Base
import os

class Page(Base):
    url=os.getenv('base_url')
    #定位元素
    #用户名
    username_loc=(By.NAME,'userName')
    #密码
    password_loc=(By.NAME,'password')
    #点击登录
    login_loc=(By.CLASS_NAME,'bigger-110')
    #断言
    dy_loc=(By.XPATH,'/html/body/div[2]/div/div[2]/ul/li[3]/a/span/span')
    #封装定位元素的方法
    def username(self):
        self.find_element(self.username_loc).clear()
        self.send_keys(self.username_loc,'admin')
    def password(self):
        self.find_element(self.password_loc).clear()
        self.send_keys(self.password_loc,'yan030220@')
    #点击登录的方法
    def login(self):
        self.click(self.login_loc)
    #封装断言定位的方法
    def dy(self):
        return self.get_text(self.dy_loc)
    #逻辑
    def login_luoji(self):
        self.open_url(self.url)
        self.username()
        self.password()
        time.sleep(10)
        self.login()





